<!DOCTYPE HTML>
<html>
   <head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>知果汇</title>
		<link href="_CSS_/bootstrap.min.css" rel="stylesheet">
		<link href="_CSS_/simple-line-icons.css" rel="stylesheet">
		<link href="_CSS_/font-awesome.min.css" rel="stylesheet">
		<link href="_CSS_/jasny-bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="_CSS_/nanoscroller.css">
		<link href="_CSS_/style.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="_CSS_/jquery-ui.css">
		<!--[if lt IE 9]>
		  <script src="js/html5shiv.min.js"></script>
		  <script src="js/respond.min.js"></script>
		<![endif]-->
		<style type="text/css">
		    body{background-color: #ffffff;}
			.row{margin-left: 0px;margin-right: 0px;}
			.radio-box{display:inline-block;width: 64px;}
			.formControls{padding-right:50px; position: relative;}
			.textarea {height: 100px;resize: none;font-size: 14px;padding: 4px;}
            .textarea-numberbar {position: absolute;right: 70px;bottom: 5px;z-index: 1;margin-bottom: 0;}
            .upload-btn {width: 120px;height: 90px;margin: 0;border: 1px dashed #a9a9a9;}
            .upload-btn img{
				display: block;
				width: 50px;
				height: 35px;
				margin-top: 10px;
				margin-left: 35px;

			}
			.upload-btn input{
				position: absolute;
			    top: 0;			  
			    margin: 0;
			    width: 120px;
			    height: 90px;
			    border: none;
			    opacity: 0;
			    filter: alpha(opacity=0);
			    cursor: pointer
			}
			.upload-img{width:120px;height: 90px;}
			.upload-img p {
				width: 120px;
				font-size: 10px;
				line-height: 16px;
			    margin-top: -35px;
			    text-align: center;
			}
			.img-info img{
				width: 120px;
				height: 90px;
			}
			.file-panel {
			    position: absolute;
			    display: none;
			    width: 120px;
			    height: 90px;
			    top: 0;
			    overflow: hidden;
			    z-index: 300;
			}
			.cancel {
			    width: 120px;
			    height: 90px;
			    background-color: rgba( 0, 0, 0, 0.5 );
			}
			 .table-btn,.table-btn:hover,.table-btn:focus{color: #ffffff;}
		</style>
    </head>
	<body>
	<article class="page-container">
		<form class="form form-horizontal" id="form-admin-add">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">勋章年份：</label>
				<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
					<select class="select form-control" id="area" name="area" size="1">
					</select>
					</span> 
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">勋章名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder="" id="talentname" name="talentname">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">地区：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="" placeholder="" id="levels" name="levels">
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				    <input class="btn btn-cancel radius" style="color: #ffffff;background-color: #a0a0a0;" type="button" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
				</div>
			</div>
		</form>
	</article>

    <script src="_JS_/jquery.min.js"></script>
    <script src="_JS_/bootstrap.min.js"></script>
    <script src="_JS_/jasny-bootstrap.min.js"></script>
    <script src="_JS_/jquery.slimscroll.min.js"></script>
    <script src="_JS_/jquery.nanoscroller.min.js"></script>
    <script src="_JS_/metismenu.min.js"></script>
    <script src="_JS_/float-custom.js"></script>
    <script type="text/javascript" src="_JS_/layer/layer.js"></script>
    <script type="text/javascript" src="_JS_/jquery.validation/1.14.0/jquery.validate.min.js"></script> 
    <script type="text/javascript" src="_JS_/jquery.validation/1.14.0/validate-methods.js"></script> 
    <script type="text/javascript" src="_JS_/jquery.validation/1.14.0/messages_zh.min.js"></script> 

	<script type="text/javascript">
	$(function(){
		var url = window.location.href;
        id = url.split("#")[1];

		$("#form-admin-add").validate({
			rules:{
				talentname:{
					required:true
				},
				area:{
					required:true
				},
				levels:{
					required:true
				},
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){
                //ajax
				var years = $(".select").val();
				var honor = $("#talentname").val();
				var levels = $("#levels").val();
				$.ajax({
					type: 'GET',
					url: "{:url('api/companys/companys_category_update')}",
					dataType: 'jsonp',
					data:{'id':id,'years':years,'honor':honor,'levels':levels},
					jsonp: 'callback',
					success: function (msg) {
						if(msg.code == 200){
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							parent.postfile(1);
						} else {
							layer.msg(msg.message, {icon: 5, time: 2000});
						}
					}
				})
			}			
		});

		$("#btn-cancel").click(function(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
		
		getfile(id);
	});
	
	function getfile(id){
		$.ajax({
			type: 'GET',
			url: "{:url('api/companys/companys_category_time')}",
			dataType: 'jsonp',
			jsonp: 'callback',
			success: function (msg) {
				if(msg.code == 200){
					for(var i=0;i<msg.data.length;i++){
						$('.select').append("<option value='"+msg.data[i].id+"'>"+msg.data[i].name+"</option>");
					}
					$.ajax({
						type: 'GET',
						url: "{:url('api/companys/companys_category_edit')}",
						dataType: 'jsonp',
						data:{'id':id},
						jsonp: 'callback',
						success: function (msg) {
							if(msg.code == 200){
								$("#talentname").val(msg.data.honor);
								$("#levels").val(msg.data.levels);
								$(".select").val(msg.data.years);
							} else {
								layer.msg(msg.message, {icon: 5, time: 2000});
							}
						}
					})
				} else {
					layer.msg('获取信息不成功!', {icon: 5, time: 2000});
				}
			}
		})
	}
	</script> 
</body>
</html>